package com.aaa.controller;

import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: auth
 * @Description: TODO
 * @Author: 86139
 * @Date: 2021/8/23 18:16
 * @Version:1.0
 **/
@RestController
public class PrepostController {
    @RequestMapping("m1")
    public String m1(){
        return "m1";
    }

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @RequestMapping("m2")
    public String m2(){
        return "m2";
    }

    @PreAuthorize("hasAnyRole('ROLE_TEST','ROLE_TEST')")
    @RequestMapping("m3")
    public String m3(){
        return "m3";
    }

    @PreAuthorize("hasRole('ROLE_TEST')")
    @RequestMapping("m4")
    public String m4(){
        return "m4";
    }
//    只能识别ROLE_
    @PreAuthorize("hasAuthority('select')")
    @RequestMapping("m5")
    public String m5(){
        return "m5";
    }

    @PostAuthorize("hasRole('ROLE_ADMIN')")
    @RequestMapping("m6")
    public String m6(){
        return "m6";
    }

    @PostAuthorize("hasAnyRole('ROLE_TEST','ROLE_TEST')")
    @RequestMapping("m7")
    public String m7(){
        return "m7";
    }

    @PostAuthorize("hasRole('ROLE_TEST')")
    @RequestMapping("m8")
    public String m8(){
        return "m8";
    }
    //    只能识别ROLE_
    @PostAuthorize("hasAuthority('select')")
    @RequestMapping("m9")
    public String m9(){
        return "m9";
    }
}
